﻿<Serializable()> Public Class cart
    Dim aLoginID As String
    Dim ProductList As New ArrayList

    Public Property LoginID() As String
        Get
            Return aLoginID
        End Get

        Set(ByVal value As String)
            aLoginID = value
        End Set
    End Property

    Public Property cart() As ArrayList
        Get
            Return ProductList
        End Get
        Set(value As ArrayList)
        End Set
    End Property

    Public Function AddProduct(ByVal objProd As product)
        Try
            ProductList.Add(objProd)
            Return 1
        Catch ex As Exception
            Return -1
        End Try
    End Function

    Public Function deleteProduct(ByVal objProd As product)
        Try
            ProductList.Remove(objProd)
            Return 1
        Catch ex As Exception
            Return -1
        End Try
    End Function

    Public Function emptyCart() As Boolean
        Dim isEmpty As Boolean = False

        If ProductList.Count > 0 Then
            ProductList.Clear()
            isEmpty = True
        End If

        Return isEmpty
    End Function

    Public Function changeQuantOrdered(ByVal objProd As product, ByVal newQty As Integer)
        Try
            objProd.quantityOrd = newQty
            Return 1
        Catch ex As Exception
            Return -1
        End Try
    End Function

End Class

<Serializable()> Public Class product

    Dim aProdNo As Integer
    Dim aDesc As String
    Dim aPrice As Decimal
    Dim aQuantityOrdered As Integer
    Dim aStoreID As String
    Dim aURL As String
    Dim aTotal As Decimal

    ' Remainder of Product variables
    Public Property ProdNo() As Integer
        Get
            Return aProdNo
        End Get
        Set(ByVal value As Integer)
            aProdNo = value
        End Set
    End Property

    Public Property Description() As String
        Get
            Return aDesc
        End Get
        Set(ByVal value As String)
            aDesc = value
        End Set
    End Property

    Public Property Price() As Decimal
        Get
            Return aPrice
        End Get
        Set(ByVal value As Decimal)
            aPrice = value
        End Set
    End Property

    Public Property quantityOrd() As Integer
        Get
            Return aQuantityOrdered
        End Get
        Set(ByVal value As Integer)
            aQuantityOrdered = value
        End Set
    End Property

    Public Property storeID() As Integer
        Get
            Return aStoreID
        End Get
        Set(ByVal value As Integer)
            aStoreID = value
        End Set
    End Property

    Public Property url() As String
        Get
            Return aURL
        End Get
        Set(ByVal value As String)
            aURL = value
        End Set
    End Property

    Public Property total() As Decimal
        Get
            Return aTotal
        End Get
        Set(ByVal value As Decimal)
            aTotal = value
        End Set
    End Property

End Class
